package com.gps.skyrc.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;

import org.litepal.crud.LitePalSupport;

import java.util.ArrayList;
import java.util.List;

/**
 * Create by ywq
 * data 2018/12/11
 */
public class HistoryData extends LitePalSupport implements Parcelable {
    private String mac = "";
    private int historyDetailId;
    private long timestamp;//时间戳 进行排序
    private int mode;//模式
    private int speed;//速度
    private int startSpeed;//直线测试起始速度  km/h
    private int endSpeed;//直线测试结束速度    km/h
    private double averageSpeed;//平均速度      海里knots
    private double maxSpeed;//最高速度          海里knots
    private int distance;//距离
    private int startDistance;//直线测试起始距离
    private int endDistance;//直线测试结束距离
    private int time;//测试时间   直线测试为毫秒级别   赛道飞行秒级别
    private float slope;//坡度 例：1.87%
    private float acceleration;//加速度
    private int maxHeight;//最大高度
    private boolean isValid = true;//是否有效  默认有效
    private List<Float> speedList = new ArrayList<>();  // 速度  海里knots
    private List<Float> accelerationList = new ArrayList<>();//加速度列表

    public HistoryData() {
    }

    protected HistoryData(Parcel in) {
        mac = in.readString();
        historyDetailId = in.readInt();
        timestamp = in.readLong();
        mode = in.readInt();
        speed = in.readInt();
        startSpeed = in.readInt();
        endSpeed = in.readInt();
        averageSpeed = in.readDouble();
        maxSpeed = in.readDouble();
        distance = in.readInt();
        startDistance = in.readInt();
        endDistance = in.readInt();
        time = in.readInt();
        slope = in.readFloat();
        acceleration = in.readFloat();
        maxHeight = in.readInt();
        isValid = in.readByte() != 0;
        in.readList(speedList,Float.class.getClassLoader());
        in.readList(accelerationList,Float.class.getClassLoader());
    }

    public static final Creator<HistoryData> CREATOR = new Creator<HistoryData>() {
        @Override
        public HistoryData createFromParcel(Parcel in) {
            return new HistoryData(in);
        }

        @Override
        public HistoryData[] newArray(int size) {
            return new HistoryData[size];
        }
    };

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }

    public int getHistoryDetailId() {
        return historyDetailId;
    }

    public void setHistoryDetailId(int historyDetailId) {
        this.historyDetailId = historyDetailId;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getStartSpeed() {
        return startSpeed;
    }

    public void setStartSpeed(int startSpeed) {
        this.startSpeed = startSpeed;
    }

    public int getEndSpeed() {
        return endSpeed;
    }

    public void setEndSpeed(int endSpeed) {
        this.endSpeed = endSpeed;
    }

    public double getAverageSpeed() {
        return averageSpeed;
    }

    public void setAverageSpeed(double averageSpeed) {
        this.averageSpeed = averageSpeed;
    }

    public double getMaxSpeed() {
        return maxSpeed;
    }

    public void setMaxSpeed(double maxSpeed) {
        this.maxSpeed = maxSpeed;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public int getStartDistance() {
        return startDistance;
    }

    public void setStartDistance(int startDistance) {
        this.startDistance = startDistance;
    }

    public int getEndDistance() {
        return endDistance;
    }

    public void setEndDistance(int endDistance) {
        this.endDistance = endDistance;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public float getSlope() {
        return slope;
    }

    public void setSlope(float slope) {
        this.slope = slope;
    }

    public float getAcceleration() {
        return acceleration;
    }

    public void setAcceleration(float acceleration) {
        this.acceleration = acceleration;
    }

    public int getMaxHeight() {
        return maxHeight;
    }

    public void setMaxHeight(int maxHeight) {
        this.maxHeight = maxHeight;
    }

    public boolean isValid() {
        return isValid;
    }

    public void setValid(boolean valid) {
        isValid = valid;
    }

    public List<Float> getSpeedList() {
        return speedList;
    }

    public void setSpeedList(List<Float> speedList) {
        this.speedList = speedList;
    }

    public List<Float> getAccelerationList() {
        return accelerationList;
    }

    public void setAccelerationList(List<Float> accelerationList) {
        this.accelerationList = accelerationList;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mac);
        dest.writeInt(historyDetailId);
        dest.writeLong(timestamp);
        dest.writeInt(mode);
        dest.writeInt(speed);
        dest.writeInt(startSpeed);
        dest.writeInt(endSpeed);
        dest.writeDouble(averageSpeed);
        dest.writeDouble(maxSpeed);
        dest.writeInt(distance);
        dest.writeInt(startDistance);
        dest.writeInt(endDistance);
        dest.writeInt(time);
        dest.writeFloat(slope);
        dest.writeFloat(acceleration);
        dest.writeInt(maxHeight);
        dest.writeByte((byte) (isValid ? 1 : 0));
        dest.writeList(speedList);
        dest.writeList(accelerationList);
    }

}
